package org.kca.yarmour.data;

public class Quest
{
    public enum QuestStatus
    {
        UNKNOWN,
        AVAILABLE,
        ACTIVE,
        READY_TO_COMPLETE,
        COMPLETED
    }
    
    private QuestDetails quest;
    private QuestStatus status;
    
    /**
     * Creates a new quest with unknown status
     * @param q the quest details
     */
    public Quest(QuestDetails q)
    {
        this (q, QuestStatus.UNKNOWN);
    }
    
    /**
     * Creates a new quest with specified quest status
     * @param q the quest details
     * @param status the quest status
     */
    public Quest(QuestDetails q, QuestStatus status) 
    {
        this.quest = q;
        this.status = status;
    }

    /**
     * Gets the quest details
     * @return the quest details
     */
    public QuestDetails getDetails()
    {
        return quest;
    }
    
    /**
     * Convenience method to get id within quest details. Equivalent to getDetails().getId()
     * @return the quest id
     */
    public String getId()
    {
        return quest.getId();
    }

    /**
     * Gets the completion state of this quest. A quest is ready to complete if all tasks 
     * for completion (except for being in the right location) are met.
     * @return true if this quest is ready to complete
     */
    public boolean isReadyToComplete()
    {
        return status == QuestStatus.READY_TO_COMPLETE;
    }
    
    /**
     * Gets the availability of this quest. A quest is available if all prerequisites for 
     * the quest (except for being in the right location) have been met. 
     * @return true if this quest is available
     */
    public boolean isAvailable()
    {
        return status == QuestStatus.AVAILABLE;
    }

    /**
     * Gets the quest status
     * @return the quest status
     */
    public QuestStatus getStatus()
    {
        return status;
    }
    
    /**
     * Sets the quest status
     * @param status the quest status
     */
    public void setStatus(QuestStatus status)
    {
        this.status = status;
    }
}
